package com.example.demo.web;

import com.example.demo.pojo.Statistics;
import com.example.demo.service.IStatisticsService;
import com.example.demo.vos.StatisticsPageRequestDto;
import com.example.demo.vos.PageResponseDto;
import com.example.demo.vos.AqiDistributeTotalStatisDto;
import com.example.demo.vos.AqiTrendTotalStatisDto;
import com.example.demo.vos.ProvinceItemTotalStatisDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/statistics")
@CrossOrigin("*")
public class StatisticsWeb {

    @Autowired
    private IStatisticsService statisticsService;

    @PostMapping("/saveStatistics")
    public int saveStatistics(@RequestBody Statistics statistics) {
        return statisticsService.saveStatistics(statistics);
    }

    @PostMapping("/listStatisticsPage")
    public PageResponseDto<Statistics> listStatisticsPage(@RequestBody StatisticsPageRequestDto statisticsPageRequestDto) {
        return statisticsService.listStatisticsPage(statisticsPageRequestDto);
    }

    @PostMapping("/getStatisticsById")
    public Statistics getStatisticsById(@RequestBody Statistics statistics) {
        return statisticsService.getStatisticsById(statistics.getId());
    }

    @GetMapping("/listProvinceItemTotalStatis")
    public List<ProvinceItemTotalStatisDto> listProvinceItemTotalStatis() {
        return statisticsService.listProvinceItemTotalStatis();
    }

    @GetMapping("/listAqiDistributeTotalStatis")
    public List<AqiDistributeTotalStatisDto> listAqiDistributeTotalStatis() {
        return statisticsService.listAqiDistributeTotalStatis();
    }

    @GetMapping("/listAqiTrendTotalStatis")
    public List<AqiTrendTotalStatisDto> listAqiTrendTotalStatis() {
        return statisticsService.listAqiTrendTotalStatis();
    }

    @GetMapping("/getAqiCount")
    public long getAqiCount() {
        return statisticsService.getAqiCount();
    }

    @GetMapping("/getAqiGoodCount")
    public long getAqiGoodCount() {
        return statisticsService.getAqiGoodCount();
    }

    @GetMapping("/getProvinceCoverage")
    public String getProvinceCoverage() {
        return statisticsService.getProvinceCoverage();
    }

    @GetMapping("/getCityCoverage")
    public String getCityCoverage() {
        return statisticsService.getCityCoverage();
    }

}
